'use strict';

const puppeteer = require('puppeteer');
const sleep = require('util').promisify(setTimeout);
const screenCompare = require('./src/compare-method/screen-compare')

async function main() {
  const browser = await puppeteer.launch({
    headless: true, // false 演示展示浏览器
  });
  try {
    const page = await browser.newPage();
    //set device to iPhone 6
    const m = puppeteer.devices['iPhone 6']
    //emulate iPhone 6
    await page.emulate(m)

    await page.goto('https://catalins.tech/');

    // 延时3秒
    await sleep(3000);

    await page.screenshot({ path: 'catalins.png' });

    const diff1 = await screenCompare();
    console.log('diff1: ', diff1);
  } catch (e) {
    console.log(e)
  } finally {
    await browser.close();
  }
}

main();